import math
import sys


def information_entropy(*l):
	if (len(l) == 1):
		sum_l = sum(l[0])
		entropy = 0
		for i in l[0]:
			if i == 0:
				continue
			entropy -= i / sum_l * (math.log(i / sum_l, 2))
		return entropy
	else:
		sum_all = 0
		sum_each = []
		entropy_each = []
		for i in l:
			sum_now = sum(i)
			sum_each.append(sum_now)
			sum_all += sum_now
			entropy_each.append(information_entropy(i))
		entropy = 0
		for i in range(len(l)):
			entropy += sum_each[i] * entropy_each[i]
		entropy /= sum_all
		return entropy


arr_str = sys.argv[1:] if len(sys.argv) > 1 else input().split(' ')

arr_int = [int(i) for i in arr_str]

print(information_entropy(arr_int))
